<template>
  <div style="border:1px solid #d3d3d3;background:white;margin-top:5px">
    <el-row style="height:40px;background:#f7f7f7;border-bottom:1px solid #d3d3d3;">
      <div>
        <el-col :span="5">
          <div style="font-size:14px;lineHeight:40px">&emsp;工时确认</div>
        </el-col>
        <el-col :span="1">
          <div style="font-size:30px;height:40px;lineHeight:40px">
            <el-divider direction="vertical"></el-divider>
          </div>
        </el-col>
        <el-col :span="6 " style="margin-left:5px;lineHeight:40px">
          <el-date-picker @change="manHoursTimeChange" class="input-class" :editable="false" v-model="dateValue" value-format="yyyy-MM-dd" type="date" placeholder="选择日期" style="width:140px;font-size:14px;margin-top:2px"></el-date-picker>
        </el-col>
      </div>
    </el-row>
    <!-- <el-row>
      <div style="height:1rem"></div>
    </el-row> -->
    <el-row>
      <el-table class="tl-table" ref="mainTable" height=255 resizable-key="tableHeight" :resizable-refs="tableResizeRefs" v-loading="loading" :data="manHoursData" @selection-change="doSelectChange" @sort-change="doSortChange" @row-dblclick="doRowDbClick" row-key="id" border fit :row-class-name="doChangeRowClassName">
        <!-- <el-table-column type="selection" width="55px"></el-table-column> -->
        <el-table-column prop="dispprojectid" label="项目名称" min-width="25%" :show-overflow-tooltip=true sortable="custom" sort-by="docno" align="center"></el-table-column>
        <el-table-column prop="name" label="任务名称" min-width="25%" :show-overflow-tooltip=true sortable="custom" sort-by="docdate" align="center"></el-table-column>
        <el-table-column prop="submitdate" label="提报日期" width="150px" sortable="custom" sort-by="submitdate" align="center" header-align="center" :formatter="dateFormat" :show-overflow-tooltip="true"></el-table-column>

        <el-table-column prop="finishexplain" label="完成情况" :show-overflow-tooltip=true min-width="25%" sortable="custom" sort-by="usercode" align="center"></el-table-column>
        <el-table-column prop="username" label="完成人" min-width="25%" :show-overflow-tooltip=true sortable="custom" sort-by="username" align="center"></el-table-column>
      </el-table>
    </el-row>
    <el-row class="pagebar" ref="pager">
      <el-pagination @size-change="doChangeSize" @current-change="doChangeIndex" :current-page="pageInfo.currentPage" :page-sizes="pageInfo.pageSizes" :total="pageInfo.totalCount" layout="total, sizes, prev, pager, next, jumper" background class="tl-table-pagination"> </el-pagination>
    </el-row>
  </div>
</template>

<script>
import { getAction } from '@tapui/utils/http'
import { mixin_list } from '@tapui/mixins/mixin_list'
import { validateNull } from '@tapui/utils/validate'
import { filterObjectNull } from '@tapui/utils/util'

// 公式确认
export default {
  name: 'manHoursConfirm',
  mixins: [mixin_list],
  data() {
    return {
      url: { list: 'pm/project/manHoursConfirm' },
      manHoursData: [],
      dateValue: '',
      dataPermissionFlagForManHour: 'org',
      isQueryOnCreated: false,
      pageInfo: {
        currentPage: 1, // 当前页面
        pageSize: 5, // 每页记录数
        pageSizes: ['5'],
        totalCount: 0 // 总数
      }
    }
  },
  methods: {
    manHoursTimeChange(param) {
      let paramMap = {}
      paramMap = Object.assign(
        { dataPermissionFlag: this.dataPermissionFlagForManHour },
        { queryDate: this.dateValue }
      )
      if (param) {
        paramMap = Object.assign(param, paramMap)
      }
      paramMap = filterObjectNull(paramMap)
      this.loadData(paramMap)
    },
    /** 页面跳转 */
    doChangeIndex(val) {
      if (this.pageInfo.currentPage !== val) {
        this.pageInfo.currentPage = val
        this.loadData({
          dataPermissionFlag: this.dataPermissionFlagForManHour,
          queryDate: this.dateValue
        })
      }
    },
    loadData(paramMap) {
      // 得到加载分页
      if (validateNull(paramMap) === false && Object.keys(paramMap).indexOf('currentPage') > -1) {
        this.pageInfo.currentPage = paramMap['currentPage']
      }
      var params = this.getQueryParams()
      params = Object.assign(params, paramMap)
      this.loading = true
      getAction(this.url.list, params).then(res => {
        if (res.success) {
          this.manHoursData = res.result.dataList
          this.pageInfo.totalCount = res.result.totalCount
        } else {
          this.$tap.alert(res.message, 'warning')
        }
        this.afterLoadData()
        this.loading = false
      })
      //   getManHoursDataList(){
      //       getAction('/pm/')
      //   }
    }
  },
  created() {}
}
</script>

<style scoped>
.input-class {
  width: 150px;
}
</style>
